#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "QTextEdit"
#include <QMainWindow>
#include "tlbbcode.h"
#include "QPushButton"
#include "utils/gametask.h"
#include "persent/runshop.h"
#include "persent/kuozhang.h"
#include "persent/zhongzhi.h"
#include "QRadioButton"
#include "QLineEdit"
#include "qxtglobalshortcut.h"
#include "QThreadPool"
#include "QTableWidget"
#include "bean/rolebean.h"
#include "roletablewidget.h"
#include "QComboBox"
#include "runshoptablewidget.h"
#include "kuozhangtablewidget.h"
#include "bean/kuozhangbean.h"
#include "zhongzhitablewidget.h"
#include "bean/zhongzhibean.h"
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
 QThread *thread;
    //接收日志
    bool event(QEvent *event);
    void test();

private:
    void initView();
    void initData();
    void registerHotKey();
    bool setXiaoWeiPoint();
    bool setGroupIndex();
    bool setRunshopCount();
    void taskRunshop(QPushButton *btn, int runStatue, int runType);
    void cancelTaskRunshop(QPushButton* btn);

    void taskZhongZhi();
    void cancelTaskZhongZhi();

    void taskKuoZhang();
    void cancelTaskKuoZhang();
    bool checkParams();
    void setButtonEnable(int task, bool isEnable);
    void setRunshopFinishView(QPushButton* btn, int runType);

private slots:
    void on_btn_saveSetting_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_kuozhang_add_clicked();

    void on_kuozhang_save_clicked();

    void on_zhongzhi_add_clicked();

    void on_zhongzhi_save_clicked();

private:
    QStatusBar *statusBar;

    QPushButton *bindGame;

    RoleTableWidget *tbRole;
    RunshopTableWidget *runshopTable;

    QPushButton *btnRunMerchant;
    QPushButton *btnRunRemote;
    QPushButton *btnRunGroup;

    KuoZhangTableWidget *kuozhangTable;
    QPushButton *btnTaskExpand;


    ZhongZhiTableWidget *zhongZhiTable;
     QPushButton *btnTaskZhongZhi;
    //复活
    QRadioButton *btnHell_ly;
    QRadioButton *btnHell_dl;
    QRadioButton *btnHell_sz;
    QRadioButton *btnHell_dhgz;



    //按键映射
    QLineEdit *leBloodKey;
    QLineEdit *leMagicKey;
    QLineEdit *leSkill;
    QLineEdit *leSkill2;
    QLineEdit *leSpeed;

    //图片识别率
    QLineEdit *leImgDiscern;
    QPushButton *btnSaveSetting;//保存设置
    QTextEdit *tvLog;//日志

    GamePersent *gamePersent = nullptr;
    GameTask *gameTask;

    Ui::MainWindow *ui;
    RunShop *runShop = nullptr;
    KuoZhang *kuoZhang = nullptr;
    ZhongZhi *zhongzhi = nullptr;

    QThreadPool *threadPool = QThreadPool::globalInstance();
    QxtGlobalShortcut *cancelTaskKey = nullptr;
    //跑商数据
    QList<RunShopBean*> *allRunShopBeans = new QList<RunShopBean*>();
    //角色数据
    QList<RoleBean*> *allRoleBeans = new QList<RoleBean*>();
    //扩张数据
    QList<KuoZhangBean*> *allKuoZhangBeans = new QList<KuoZhangBean*>();

    QList<ZhongZhiBean *> *allZhongZhiBeans = new QList<ZhongZhiBean*> ();

    bool intRunshopData(bool isNeedFindPath = false);
    bool intKuoZhangData(bool isNeedFindPath = false);
    bool intZhongZhiData();

};

#endif // MAINWINDOW_H
